<?php

require_once '../scripts/config.php';
require_once '../scripts/functions.php';

/* fix path to this file in client */

file_put_contents("penis", $_GET['proxy']);

if((int)getVersion("client") == (int)$_GET['proxy']){
  if(authenticateUser($_POST['user'], $_POST['password'])){
    $sessid = generateSessionId();
    $query='
      Update  `'.$config['mysql']['database'].'`.`Users`
      Set     session = "'.$sessid.'"
      Where   username = "'.$_POST['user'].'"
    ';
    
    $success = runQuery($query);
    if($success){
      echo '1309520900000:randomtoken:'.$_POST['user'].':'.$sessid;
    } else {
	echo "Error restart Minecraft";
    }
  } else {
    echo "Bad login";
  }
} else {
  echo "Update Proxy";
}
?>